Session Provider & Context
Understand the usage of the SessionWalletProvider and the context it provides, enabling easy access to the session wallet functionalities across your application components?
SessionWalletProvider
is a higher-order component that wraps around your app components to provide the sessionWallet
context throughout the application.
Here’s an example of how to use the SessionWalletProvider
:
- Create a new file named
components/SessionProvider.tsx
- In your
_app.tsx
file, wrap the SessionProvider around the entire app to ensure it’s accessible within every component:
Note: Ensure that all your Solana wallet adapter contexts are the parent of the SessionProvider.
- With the SessionWalletProvider set up, you can now use the
useSessionWallet
hook in your components:
Using useSessionWallet
in components
useSessionWallet
is a custom hook that provides access to the session wallet context value. Use this hook in any component wrapped by the SessionWalletProvider.
Was this page helpful?